﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            var uid = textUser.Text;
            var pwd = textPwd.Text;

            var sql = string.Format("select * from users where usersname='{0}'", uid);

            var dt = DbHelper.GetDatatable(sql);
            var item = dt.Rows[0];

            var IsActived = (bool)item.ItemArray[3];
            var IsDelete = (bool)item.ItemArray[4];
            var password = item.ItemArray[2].ToString();

            if (dt.Rows.Count == 1)
            {
                if (IsDelete)
                {
                    Labe3.Text = "该用户已被删除";
                }
                else
                {
                    if (IsActived)
                    {
                        if (pwd == password)
                        {
                            Response.Redirect("default.aspx");
                        }
                        else
                        {
                            Labe3.Text = "登录失败，密码错误";
                        }
                    }
                    else
                    {
                        Labe3.Text = "过期";
                    }
                }
            }
            else
            {
                Labe3.Text = "用户名或密码错误";
            }
        }
    }
}